Repository navigation
[meta] attrversion.sh: only emit versions for attributes in the checked-out headers - #2363
Conversation
…ed-out headers attrversion.sh collects SAI_METADATA_ATTR_VERSION_* from every vX.Y.Z tag from v1.10.0 up. A clone usually carries all upstream tags, including releases published after the checked-out commit or on newer release branches, so attributes that do not exist in the checked-out headers were emitted too, and the output changed whenever a new release was tagged. For example, v1.17.5 checked out in a clone that has v1.19.1 produced 5821 defines for 2650 attributes in its headers. Downstream users that build metadata from a pinned SAI (e.g. the sonic-sairedis Python binding) saw unchanged sources start failing to build once v1.19.1 was tagged. Keep scanning the same tags, but only emit a define for attributes found in the checked-out headers. Unlike restricting to tags merged into HEAD, this keeps backported attributes at the point release that first shipped them. Every remaining attribute keeps the version of the first tag that contains it, so the generated metadata is unchanged apart from SAI_METADATA_HAVE_ATTR_VERSION; defines for attributes removed from the headers (e.g. the DASH meter bucket attributes) are dropped. Fixes opencomputeproject#2361 Signed-off-by: Terence Hui <terence@nexthop.ai>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thanks for digging into this and for the detailed writeup on #2361 — you're right that I reproduced your results independently: checked out
This matches your test table exactly. The approach (buffer all tag/attr pairs, gate emission on presence in the LGTM — approving. Would also support backporting this to |
| # A clone usually carries every upstream tag, including releases published | ||
| # after (or on branches newer than) the checked-out commit. Only emit versions | ||
| # for attributes present in the checked-out headers, so that the output does not | ||
| # depend on which tags exist in the clone. |
There was a problem hiding this comment.
i already replied on issue for this
Fixes #2361
Problem
meta/attrversion.shcollectsSAI_METADATA_ATTR_VERSION_*from everyvX.Y.Ztag fromv1.10.0up. A clone usually carries all upstream tags, including releases published after the checked-out commit or cut on newer release branches. So the script emitted defines for attributes that do not exist in the checked-out headers, and its output changed whenever a new release was tagged.For example,
v1.17.5checked out in a clone that hasv1.19.1produces 5,821 defines for the 2,650 attributes in its headers.sonic-sairedis's SWIG binding turns every define into a constant, and the extra ones pushpysairedis_wrap.cpppast GCC'smax-gcse-memory(-Werror=disabled-optimization). That broke builds of unchanged pinned commits oncev1.19.1was tagged (worked around in sonic-net/sonic-sairedis#2108 and #2109).Change
The script keeps scanning the same tags, but it now buffers the scan and only prints a define for attributes found in the checked-out headers (committed
HEADor working tree). Every remaining attribute keeps the version of the first tag that contains it, as before.Why not
git tag --merged HEAD(as suggested in #2361)Point releases are tagged on release branches, and those tags are usually not ancestors of
masteror of later branches. With--merged HEAD, attributes first released in a point release get the next ancestor tag's version instead. That changes 106 versions onmaster, 94 onv1.18and 59 onv1.17. For example,SAI_ACL_TABLE_ATTR_FIELD_NEXT_HOP_USER_METAmoves fromv1.17.1tov1.18.0. These versions feedsai_attr_metadata_t.apiversion, which syncd compares with the vendor'ssai_query_api_version().Ignoring tags newer than
inc/saiversion.hwas also considered. It mislabels attributes too, becausemaster's version often lags release-branch point releases: atf60c11f(1.18.0, withv1.18.1already released) it changes 12 attributes fromv1.18.1toHEAD.Testing
All tests were run against a full clone with tags up to
v1.19.1, comparing the old and new script on the same commit. Thev1.19branch tip is currently the same commit asmaster, so themasterresults cover it:master/v1.19fc7e71b(1.19.1)v1.18c67f115(1.18.1)v1.170ac228e(1.17.5)masterf60c11f(1.18.0)metamake: run as in CI (plain, and withdoc/custom-headerscopied intocustom/) onmaster/v1.19,v1.18andv1.17, in a Debian bookworm environment with doxygen 1.9.4 and GCC 12.saimetadata.c, are byte-identical. The only exception isSAI_METADATA_HAVE_ATTR_VERSIONinsaimetadata.h.no version defined.makewas run withsize.shpointed atHEAD. Its hardcodedorigin/masterfails the struct-size check there, whichever version of this script is used.HEADlabel: attributes that are not in any release (the custom-header attributes, a local commit, an uncommitted edit) are still labelledHEAD.master, the 12 removed are for DASH meter attributes (SAI_METER_BUCKET_ATTR_*and related) that Convert DASH meter bucket object to table entry #2056 removed from the headers.Notes
HEADtoday, or labelled with a later branch's release, gets the version of the first release that contains it, wherever that release was tagged. That's what the version means. It doesn't change the number of defines.